package com.leiting.mail.util.properties.factory.builder;

import com.leiting.mail.util.MailConstant;
import com.sun.mail.util.MailSSLSocketFactory;

import java.security.GeneralSecurityException;
import java.util.Properties;


public class MailSmtpSSLStorePropertiesBuilder {

    private MailSmtpSSLStorePropertiesBuilder(){}

    public static Properties build(String pop3Server){
        Properties prop = new Properties();
        prop.setProperty("mail.store.protocol", MailConstant.PROTOCOL_TYPE_SMTP);
        prop.setProperty("mail.smtp.host", pop3Server);
        prop.setProperty("mail.smtp.port", "465");
        prop.setProperty("mail.smtp.auth", "true");
        MailSSLSocketFactory sf = null;
        try {
            sf = new MailSSLSocketFactory();
            sf.setTrustAllHosts(true);
        } catch (GeneralSecurityException e1) {
            e1.printStackTrace();
        }
        prop.put("mail.smtp.ssl.enable", "true");
        prop.put("mail.smtp.ssl.socketFactory", sf);
        return prop;
    }
}
